﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CMSService
{
    /// <summary>
    /// 用户回复表
    /// </summary>
    public class UserReplyService : ICMS.IUserReply
    {
        DavidDB.ADO.DBManager db = null;
        private UserReplyService()
        {
            db = new DavidDB.ADO.DBManager();
        }
        public UserReplyService(DavidDB.ADO.DBManager db)
        {
            this.db = db;
        }


        /// <summary>
        /// 获取一个网站用户回复
        /// </summary>
        /// <param name="id">用户回复编号</param>
        /// <returns>网站用户回复，如果没有，返回Null</returns>
        public CMSModel.UserReply GetModel(int id)
        {
            CMSModel.UserReply returnValue = new CMSModel.UserReply();
            returnValue.Id = id;
            returnValue = db.GetModel(returnValue);
            return returnValue;
        }
        /// <summary>
        /// 删除一个网站用户回复
        /// </summary>
        /// <param name="id">用户回复编号</param>
        /// <returns>成功删除，返回0，没有当前用户回复，返回-1</returns>
        public int Delete(int id)
        {
            int returnValue = (int)CMSModel.DBOperatorStatus.Success;
            CMSModel.UserReply model = new CMSModel.UserReply();
            model.Id = id;
            db.Delete(model);
            return returnValue;
        }
        /// <summary>
        /// 增加一个网站用户回复
        /// </summary>
        /// <param name="announcement">网站用户回复实体</param>
        /// <returns>增加成功，返回0</returns>
        public int Insert(CMSModel.UserReply userReply)
        {
            int returnValue = (int)CMSModel.DBOperatorStatus.Success;
            db.Insert(userReply);
            return returnValue;
        }
        /// <summary>
        /// 编辑一个用户回复
        /// </summary>
        /// <param name="announcement">编辑完成的用户回复</param>
        /// <returns>编辑成功，返回0</returns>
        public int Edit(CMSModel.UserReply userReply)
        {
            int returnValue = (int)CMSModel.DBOperatorStatus.Success;
            db.Edit(userReply);
            return returnValue;
        }
        /// <summary>
        /// 到底最新的count条记录
        /// </summary>
        /// <param name="count">查询条数</param>
        /// <returns>如果记录足够多，返回count条，否则，返回所有记录</returns>
        public List<CMSModel.UserReply> GetList(int count)
        {
            List<CMSModel.UserReply> lists = new List<CMSModel.UserReply>();
            var query = db.GetTopList(count, new CMSModel.UserReply());
            foreach (CMSModel.UserReply model in query)
            {
                lists.Add(model);
            }
            return lists;
        }



    }
}
